package com.ruoyi.filler.controller;

import com.github.pagehelper.PageHelper;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.consumer.domain.CRequirement;
import com.ruoyi.consumer.service.impl.CRequirementServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: lizhouwei
 * @ date : 2023/10/19
 * @description:
 */
@Api(tags = "接单员需求")
@RestController
@RequestMapping("/api/Filler/requirement")
public class FillerRequirementController {

    @Autowired
    private CRequirementServiceImpl requirementService;


    /**
     * 我接的需求列表
     * @param fillerId
     * @param status
     * @param pageNum
     * @param pageSize
     * @return
     * @Description:    *0为需求大厅全部未接需求
     *                  *1为我已接需求
     *                  *2为我已完成需求
     */
    @ApiOperation("需求列表")
    @GetMapping("/getList")
    public AjaxResult requirementList(@ApiParam(value = "加注员id", required = true) Integer fillerId,
                                      @ApiParam(value = "列表标识", required = true) Integer status,
                                      @ApiParam(value = "页码", required = true) Integer pageNum,
                                      @ApiParam(value = "页数", required = true) Integer pageSize) {
        Assert.notNull(fillerId, "消费者id不能为空");
        PageHelper.startPage(pageNum, pageSize);
        PageHelper.orderBy("create_time desc");
        CRequirement cRequirement = new CRequirement();
        if (status == 0){
            cRequirement.setStatus(0);
        }
        if (status == 1){
            cRequirement.setFillerId(fillerId);
            cRequirement.setStatus(1);
        }
        if (status == 2){
            cRequirement.setFillerId(fillerId);
            cRequirement.setStatus(2);
        }
        return AjaxResult.success(requirementService.selectCRequirementList(cRequirement));
    }
}
